<template lang="">
  <div class="center">
    <div class="main" style="border: 1px solid #fff;height: auto;background-color: #fff;border-radius: 10px;">
      <div class="top" style="border: 0px solid #000;background-color: #fff;border-radius: 10px;margin: 30px 50px;">
        <div class="title"
          style="text-align: left;margin-top:30px;border-left: 3px solid #fe0100;width: 100px;height: 25px;">
          <h3 style="color:#161616 ;font-weight: 500;font-size: 18px;padding-left: 15px;">客户详情</h3>
        </div>

        <div v-if="type === 1" class="bx" style="border: 0px solid #000;width: 550px;margin: 40px 20px;">
          <el-form ref="userData" :model="userData" label-width="130px">
            <el-form-item label="客户名称">
              <el-input v-model="userData.username"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item label="客户类型">
              <el-select v-model="userData.customType" placeholder="请选择客户类型" clearable
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;">
                <el-option v-for="item1 in dictList1" :key="item1.dictId" :label="item1.dictKey" :value="item1.dictKey">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户来源">
              <el-input v-model="userData.customSource"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item label="单位星级">
              <el-rate style="margin-top: 10px;" v-model="userData.grade"></el-rate>
            </el-form-item>
           
            <el-form-item label="行业">
              <el-select v-model="userData.industry" placeholder="请选择行业" clearable
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;" @change="getDepartmentList()">
                <el-option v-for="item1 in industryList" :key="item1.dictId" :label="item1.dictValue"
                  :value="item1.dictValue">
                </el-option>
              </el-select>
              <i @click="dialogFormVisible2 = true" class="el-icon-plus"
                style="position: absolute;top: 15px;left: 320px;color: #0060ff;font-weight: 700;cursor: pointer;"></i>
            </el-form-item>
            <el-form-item label="单位类型">
              <el-select v-model="userData.departmentType" placeholder="请选择单位类型" clearable
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;">
                <el-option v-for="(item2,index1) in departmentList" :key="item2.index1" :label="item2.dictValue"
                  :value="item2.dictValue">
                </el-option>
              </el-select>
              <i @click="dialogFormVisible3 = true" class="el-icon-plus"
                style="position: absolute;top: 15px;left: 320px;color: #0060ff;font-weight: 700;cursor: pointer;"></i>
            </el-form-item>
            <el-form-item label="所属单位">
              <el-input v-model="userData.company"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item label="区域">
              <el-select v-model="userData.province" placeholder="请选择省份" clearable
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"
                @change="getCityList()">
                <el-option v-for="item in dictList" :key="item.dictId" :label="item.dictKey" :value="item.dictKey">
                </el-option>
              </el-select>
              <i @click="dialogFormVisible = true" class="el-icon-plus"
                style="position: absolute;top: 15px;left: 320px;color: #0060ff;font-weight: 700;cursor: pointer;"></i>
              <el-select v-model="userData.city" placeholder="请选择市" clearable
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;">
                <el-option v-for="(item,index) in cityList" :key="item.index" :label="item.dictValue"
                  :value="item.dictValue"></el-option>
              </el-select>
              <i @click="dialogFormVisible1 = true" class="el-icon-plus"
                style="position: absolute;top: 70px;left: 320px;color: #0060ff;font-weight: 700;cursor: pointer;"></i>
            </el-form-item>
            <el-form-item label="地址">
              <el-input v-model="userData.adress"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item label="联系电话">
              <el-input v-model="userData.phone"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item label="网址">
              <el-input v-model="userData.information" type="textarea" autosize
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 10px;overflow: hidden;"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button @click="updateCustom()" type="danger" class="button">确定</el-button>
              <el-button @click="type = 0" type="danger" class="button">取消</el-button>
            </el-form-item>
          </el-form>
        </div>

        <div v-else class="bx" style="border: 0px solid #000;width: 550px;margin: 40px 20px;">
          <ul style="list-style: none;padding: 0;margin:0;">
            <li v-model="userData" style="text-align: left;margin-left: 15px">
              <p>
                <span class="title">客户名称 </span>
                <span class="blue">{{userData.username}}</span>
              </p>
              <p>
                <span class="title">客户类型 </span>
                <span>{{userData.customType}}</span>
              </p>
              <p>
                <span class="title">客户来源 </span>
                <span>{{userData.customSource}}</span>
              </p>
              <p>
                <span class="title">单位星级 </span>
                <el-rate style="margin-left: 85px;margin-top: -20px;" v-model="userData.grade" disabled></el-rate>

              </p>
              <p>
                <span class="title">联系电话 </span>
                <span>{{userData.phone}}</span>
              </p>

              <!-- <p>
                <span class="title" style="margin-left: 30px;">邮箱</span>
                <span>{{userData.email}}</span>
              </p> -->
              <p>
                <span class="title" style="margin-left: 30px;">行业</span>
                <span>{{userData.industry}}</span>
              </p>
              <p>
                <span class="title">单位类型</span>
                <span>{{userData.departmentType}}</span>
              </p>
              <p>
                <span class="title" v-if="userData.userType=='2'">所属单位 </span>
                <span v-if="userData.userType=='2'">{{userData.company}}</span>
                <span v-if="userData.userType=='3'"></span>
                <span v-if="userData.userType=='3'"></span>
              </p>
              <p>
                <span class="title" style="margin-left: 30px;">区域</span>
                <span>{{userData.province}}{{userData.city}}</span>
              </p>
              <p>
                <span class="title" style="margin-left: 30px;">网址</span>
                <span><a href="http://www.wjzsk.cn/" target="_blank">{{userData.information}}</a></span>
              </p>
              
              <p>
                <span class="title" style="margin-left: 30px;">地址</span>
                <span>{{userData.adress}}</span>
              </p>

            </li>
          </ul>
          <el-button @click="type = 1" type="danger" class="button">编辑</el-button>
          <el-button style="width:150px" @click="dialogVisible = true" type="danger" class="button">添加联系人</el-button>
          <el-button @click="goBack()" type="danger" class="button">返回</el-button>
          </el-button>
          <p style="border: 0px solid #000;width: 500px;">
            <span class="title"
              style="color:#161616 ;font-weight: 500;font-size: 18px;padding-left: 15px;border-left: 3px solid #fe0100;margin-left: -450px;">合同列表</span>
          <ul style="text-align: left;margin-left: 25px;list-style: none;">
            <li v-model="agreList" @click="Detail(agreList)">
              <div class="title" v-if="agreList.contractId==''">
                <i class="el-icon-paperclip" style="margin-right: 5px;"></i>
                <a href="#">{{agreList.contractName}}</a>
                <span style="margin-left: 50px;">{{(parseFloat(agreList.contractAmount)).toLocaleString('zh-CN', {
                  style: 'currency', currency:
                  'cny', currencyDisplay: 'symbol' })}}</span>
              </div>
              <div class="title" v-if="agreList.contractId!=''">
              </div>
            </li>
          </ul>
          </p>
        </div>
        <!-- 添加行业弹框 -->
        <el-dialog :visible.sync="dialogFormVisible2">
          <el-form v-model="industryData">
            <el-form-item>
              <el-input v-model="industryData.dictValue" autocomplete="off" placeholder="请添加行业"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 10px;overflow: hidden;"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="clean2" type="danger" class="button">取 消</el-button>
            <el-button type="danger" class="button" @click="addIndustry">确 定</el-button>
          </div>
        </el-dialog>
         <!-- 添加单位类型弹框 -->
      <el-dialog :visible.sync="dialogFormVisible3">
        <el-form v-model="departmentData">
          <el-select v-model="industryData.dictValue" placeholder="请选择行业"
            style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;">
            <el-option v-for="item in industryList" :key="item.dictId" :label="item.dictValue" :value="item.dictValue">
            </el-option>
          </el-select>
          <el-form-item placeholder="请添加单位类型">
            <el-input v-model="departmentData.dictValue" autocomplete="off"
              style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible3 = false" type="danger" class="button">取 消</el-button>
          <el-button @click="addDepartment" type="danger" class="button">确 定</el-button>
        </div>
      </el-dialog>
        <!-- 添加省弹框 -->
        <el-dialog :visible.sync="dialogFormVisible">
          <el-form v-model="dictData">
            <el-form-item>
              <el-input v-model="dictData.dictKey" autocomplete="off" placeholder="请添加省会"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 10px;overflow: hidden;"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="clean" type="danger" class="button">取 消</el-button>
            <el-button type="danger" class="button" @click="addDict">确 定</el-button>
          </div>
        </el-dialog>
        <!-- 添加市弹框 -->
        <el-dialog :visible.sync="dialogFormVisible1">
          <el-form v-model="cityData">
            <el-select v-model="dictData.dictKey" placeholder="请选择省份"
              style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;">
              <el-option v-for="item in dictList" :key="item.dictId" :label="item.dictKey" :value="item.dictKey">
              </el-option>
            </el-select>
            <el-form-item placeholder="请添加市">
              <el-input v-model="cityData.dictValue" autocomplete="off"
                style="border:1px solid #b6b6b6;width: 300px;border-radius: 50px;overflow: hidden;"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="clean1" type="danger" class="button">取 消</el-button>
            <el-button type="danger" class="button" @click="addCity">确 定</el-button>
          </div>
        </el-dialog>
        <!-- 联系人列表 -->
        <div class="tabs" style="border: 0px solid #000;border-radius: 10px;overflow: hidden;text-align: center;">
          <div class="title"
            style="text-align: left;margin-top:30px;border-left: 3px solid #fe0100;width: 300px;height: 25px;">
            <h3 style="color:#161616 ;font-weight: 500;font-size: 18px;padding-left: 15px;">联系人列表</h3>
          </div>
          <el-table :data="linkmanList" stripe style="width: 100%;text-align: center;cursor: pointer;margin: 30px 0;"
            @row-dblclick="handleSelectionChange">
            <el-table-column prop="name" label="联系人姓名" width="150">
            </el-table-column>
            <el-table-column prop="department" label="部门" width="150">
            </el-table-column>
            <el-table-column prop="duty" label="职务" width="150">
            </el-table-column>
            <el-table-column prop="linkmanType" label="等级" width="80">
            </el-table-column>
            <el-table-column prop="phone" label="电话" width="150">
            </el-table-column>
            <el-table-column prop="sex" label="性别" width="60" :formatter="columnFormat">
            </el-table-column>
            <el-table-column prop="age" label="年龄" width="60">
            </el-table-column>
            <el-table-column prop="nativePlace" label="籍贯" width="140">
            </el-table-column>
            <el-table-column prop="college" label="毕业院校" width="150">
            </el-table-column>
            <el-table-column prop="adress" label="家庭地址" width="200">
            </el-table-column>
            <!-- <el-table-column prop="otherMessage" label="其他信息" width="200">
          </el-table-column> -->
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button @click="updateButton(scope.row)" class="cz-button" type="danger"><span
                    style="position: relative;top: -6px;">修改</span></el-button>
                <el-button @click="deleteLinkman(scope.row)" class="cz-button" type="danger"><span
                    style="position: relative;top: -6px;">删除</span></el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination style="margin:20px;text-align: right;" @current-change="handleCurrentChange" :page-size="size"
            :current-page="current" :total="total" layout="prev, pager, next">
          </el-pagination>
        </div>
        <!-- 添加联系人 -->
        <div class="add">
          <el-dialog title="联系人添加" :visible.sync="dialogVisible">
            <el-form>
              <el-form-item label="姓名">
                <el-input v-model="linkmanData.name" placeholder="请输入内容"></el-input>
              </el-form-item>
              <el-form-item label="等级" placeholder="请输入内容">
                <el-select v-model="linkmanData.linkmanType" placeholder="请选择" clearable>
                  <el-option label="决策层" value="决策层"></el-option>
                  <el-option label="执行层" value="执行层"></el-option>
                  <el-option label="内线" value="内线"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="部门级别" placeholder="请选择">
                <el-radio-group v-model="linkmanData.departmentLevel">
                  <el-radio label="0">单位领导</el-radio>
                  <el-radio label="1">部门领导</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="部门" placeholder="请输入内容">
                <el-input v-model="linkmanData.department">
                </el-input>
              </el-form-item>
              <el-form-item label="职务" placeholder="请输入内容">
                <el-input v-model="linkmanData.duty">
                </el-input>
              </el-form-item>
              <el-form-item label="电话" placeholder="请输入内容">
                <el-input v-model="linkmanData.phone">
                </el-input>
              </el-form-item>
              <el-form-item label="性别" placeholder="请输入内容">
                <el-radio-group v-model="linkmanData.sex">
                  <el-radio label="0">男</el-radio>
                  <el-radio label="1">女</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="年龄" placeholder="请输入内容">
                <el-input v-model="linkmanData.age">
                </el-input>
              </el-form-item>
              <el-form-item label="生日" placeholder="请输入内容">
                <el-input v-model="linkmanData.birthday">
                </el-input>
              </el-form-item>
              <el-form-item label="籍贯" placeholder="请输入内容">
                <el-input v-model="linkmanData.nativePlace">
                </el-input>
              </el-form-item>
              <el-form-item label="毕业院校" placeholder="请输入内容">
                <el-input v-model="linkmanData.college">
                </el-input>
              </el-form-item>
              <el-form-item label="地址" placeholder="请输入内容">
                <el-input v-model="linkmanData.adress">
                </el-input>
              </el-form-item>
              <el-form-item label="联系人星级">
                <el-rate style="margin-top: 10px;" v-model="linkmanData.starLevel"></el-rate>
              </el-form-item>
              <el-form-item label="简历" placeholder="请输入内容">
                <el-input v-model="linkmanData.otherMessage"></el-input>
              </el-form-item>
              <el-form-item label="备注" placeholder="请输入内容">
                <el-input v-model="linkmanData.remark">
                </el-input>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: center;margin-top: 20px; cursor: pointer; ">
              <el-button @click="empty" class="button">取 消</el-button>
              <el-button type="primary" @click="addLinkman()" class="button">添 加</el-button>
            </div>
          </el-dialog>
        </div>
        <!-- 修改联系人 -->
        <div class="add">
          <el-dialog title="联系人修改" :visible.sync="dialogVisible1">
            <el-form>
              <el-form-item label="姓名">
                <el-input v-model="updateRow.name" placeholder="请输入内容"></el-input>
              </el-form-item>
              <el-form-item label="等级" placeholder="请输入内容">
                <el-select v-model="updateRow.linkmanType" placeholder="请选择" clearable>
                  <el-option label="决策层" value="决策层"></el-option>
                  <el-option label="执行层" value="执行层"></el-option>
                  <el-option label="内线" value="内线"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="部门级别" placeholder="请选择">
                <el-radio-group v-model="linkmanData.departmentLevel">
                  <el-radio label="0">单位领导</el-radio>
                  <el-radio label="1">部门领导</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="部门" placeholder="请输入内容">
                <el-input v-model="updateRow.department">
                </el-input>
              </el-form-item>
              <el-form-item label="职务" placeholder="请输入内容">
                <el-input v-model="updateRow.duty">
                </el-input>
              </el-form-item>
              <el-form-item label="电话" placeholder="请输入内容">
                <el-input v-model="updateRow.phone">
                </el-input>
              </el-form-item>
              <el-form-item label="性别" placeholder="请输入内容">
                <el-radio-group v-model="updateRow.sex">
                  <el-radio label="0">男</el-radio>
                  <el-radio label="1">女</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="年龄" placeholder="请输入内容">
                <el-input v-model="updateRow.age">
                </el-input>
              </el-form-item>
              <el-form-item label="籍贯" placeholder="请输入内容">
                <el-input v-model="updateRow.nativePlace">
                </el-input>
              </el-form-item>
              <el-form-item label="毕业院校" placeholder="请输入内容">
                <el-input v-model="updateRow.college">
                </el-input>
              </el-form-item>
              <el-form-item label="地址" placeholder="请输入内容">
                <el-input v-model="updateRow.adress">
                </el-input>
              </el-form-item>
              <el-form-item label="联系人星级">
                <el-rate style="margin-top: 10px;" v-model="updateRow.starLevel"></el-rate>
              </el-form-item>
              <el-form-item label="简历" placeholder="请输入内容">
                <el-input v-model="updateRow.otherMessage"></el-input>
              </el-form-item>
              <el-form-item label="备注" placeholder="请输入内容">
                <el-input v-model="updateRow.remark">
                </el-input>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: center;margin-top: 20px; cursor: pointer; ">
              <el-button @click="dialogVisible1 = false" class="button">取 消</el-button>
              <el-button type="primary" @click="updateLinkman()" class="button">修改</el-button>
            </div>
          </el-dialog>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    inject: ['reload'],
    data() {
      return {
        dialogFormVisible1: false,
        dialogFormVisible: false,
        dialogFormVisible2: false,
        dialogFormVisible3: false,
        dictList: [],
        cityList: [],
        dictList1: [],//客户类型列表
        industryList: [],  //行业
        departmentList:[],  //单位类型
        dictVar: '',
        industryData: {
          dictVar: 'industry',
          // dictKey: '',
          dictValue: '',
        },
        departmentData: {
          dictVar: '',
          dictKey: '',
          dictValue: '',
        },
        dictData: {
          dictVar: 'province',
          dictKey: '',
          dictValue: '',
        },
        cityData: {
          dictVar: '',
          dictKey: '',
          dictValue: '',
        },
        current: 1,
        size: 7,
        total: 0,
        userData: {},
        agreList: [],   //合同列表
        dictList: [],
        dictVar: '',
        contractId: '',
        contractName: '',
        linkmanData: {
          customId: '',
          name: '',
          phone: '',
          adress: '',
          otherMessage: '',
          remark: '',
          linkmanType: '',
          department: '',
          birthday: '',
          duty: '',
          age: '',
          sex: '',
          college: '',
          native: '',
          starLevel: '',
          departmentLevel: ''
        },
        updateRow: {},
        linkmanList: [],
        type: 0,
        userId: '',
        dialogVisible: false,
        dialogVisible1: false,
      }
    },
    mounted() {
      this.linkmanData.customId = this.$route.query.userId
      this.userId = this.$route.query.userId
      this.getUserDetail()
      this.getDictList()
      this.getDictList1()
      this.getIndustryList()
      
    },
    methods: {
      goBack() {
        this.$router.push({ path: '/custem' });
      },
      handleCurrentChange(val) {
        this.current = val
        this.getUserLinkman()
      },
      columnFormat(row, column) {
        switch (column.property) {
          case "sex":
            var sex = ["男", "女"]
            var value = sex[Number(row[column.property])]
            break;
        }
        return value;
      },
      clean() {
        this.dictData = ''
        this.dialogFormVisible = false;
      },
      clean1() {
        this.cityData = ''
        this.dialogFormVisible1 = false;
      },
      clean2() {
        this.industryData = ''
        this.dialogFormVisible2 = false;
      },
      //行业
      async getIndustryList() {
        // 解构出参数
        // const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: 'industry'
        }
        let result = await this.$API.dict.reqDictList(data)
        this.industryList = result.data.data
        

      },
      //单位类型      
      async getDepartment() {
        // 解构出参数
        // this.userData.departmentType = ''
        const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: this.userData.industry
        }
        let result = await this.$API.dict.reqDictList(data)
        this.departmentList = result.data.data
      },
       //单位类型      
       async getDepartmentList() {
        // 解构出参数
        this.userData.departmentType = ''
        const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: this.userData.industry
        }
        let result = await this.$API.dict.reqDictList(data)
        this.departmentList = result.data.data
      },
      //  添加行业
      addIndustry() {
        // 解构出参数        
        var data = this.industryData;
        // this.industryData.dictValue = this.industryData.dictKey
        this.$API.dict.reqAddDict(data).then(res => {
          if (res.data.code == 200) {
            this.$message.success("添加成功！");
            // this.industryData = ''           
            this.dialogFormVisible2 = false;
            
            this.getIndustryList();
            // this.reload();
          } else {
            this.$message.error("添加失败！");
          }
        })
      },
      //  添加单位类型
      addDepartment() {
        // 解构出参数        
        var data = this.departmentData;
        this.departmentData.dictVar = this.industryData.dictValue
        this.departmentData.dictKey = this.departmentData.dictValue
        this.$API.dict.reqAddDict(data).then(res => {
          if (res.data.code == 200) {
            this.$message.success("添加成功！");
            this.dialogFormVisible3= false;
            this.reload();
            this.getDepartmentList();
          } else {
            this.$message.error("添加失败！");
          }
        })
      },
      // 联系人详情跳转
      handleSelectionChange(val) {
        console.log(val)
        this.currentRow = val;
        this.$router.push({
          path: '/custem/linkman',
          name: 'linkmanDetail',
          query: {
            linkmanId: this.currentRow.linkmanId,
          }
        });
      },
      // 添加联系人
      addLinkman() {
        var data = this.linkmanData;
        if (data.name == '' && data.departmentLevel == '') {
          this.$message("联系人名称不能为空")
        } else if (data.departmentLevel == '') {
          this.$message("联系人级别不能为空")
        } else {
          this.$API.linkman.reqAddLinkman(data).then(res => {
            if (res.data.code == 200) {
              this.$message.success("添加成功！");
              this.dialogVisible = false;
              this.getUserLinkman();
            } else {
              this.$message.error("添加失败！");
            }
          })
        }
      },
      // 联系人清空
      empty() {
        this.linkmanData.name = ""
        this.linkmanData.phone = ""
        this.linkmanData.adress = ""
        this.linkmanData.otherMessage = ""
        this.linkmanData.remark = ""
        this.linkmanData.linkmanType = ""
        this.linkmanData.department = ""
        this.linkmanData.duty = ""
        this.linkmanData.age = ""
        this.linkmanData.sex = ""
        this.linkmanData.college = ""
        this.linkmanData.native = ""
        this.dialogVisible = false
      },
      // 删除联系人
      deleteLinkman(row) {
        this.$confirm("确认删除联系人吗？", "提示", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          var data = {
            linkmanId: row.linkmanId
          }
          this.$API.linkman.deleteLinkman(data).then(res => {
            if (res.data.code == 200) {
              this.$message.success("删除成功！");
              this.getUserLinkman()
            } else {
              this.$message.error("删除失败！");
            }
          })
        })
      },

      // 编辑客户信息
      updateCustom() {
        if (this.username == '') {
          this.$message("客户名称不能为空")
        } else {
          var data = this.userData
          // 获取资源列表接口
          this.$API.user.updateStaffy(data).then(res => {
            if (res.data.code == 200) {
              this.$message.success("修改成功！");
              this.type = 0
            } else {
              this.$message.error("修改失败！");
            }
          })
        }
      },
      //reqLinkmanList获取联系人
      getUserLinkman() {
        var data = {
          customId: this.userId,
          current: this.current,
          size: this.size,
        }
        this.$API.linkman.reqLinkmanList(data).then(res => {
          if (res.data.code == 200) {
            this.linkmanList = res.data.data
          } else {
            this.$message.error("查询失败！");
          }
        })
      },
      updateButton(row) {
        console.log(row)
        this.updateRow = row;

        this.dialogVisible1 = true;
      },
      //修改联系人
      updateLinkman() {
        if (data.departmentLevel == '') {
          this.$message("联系人级别不能为空")
        } else {
          var data = this.updateRow
          this.$API.linkman.updateLinkman(data).then(res => {
            if (res.data.code == 200) {
              this.$message.success("修改成功！");
              this.dialogVisible1 = false;
              this.getUserLinkman()
            } else {
              this.$message.error("修改失败！");
            }
          })
        }
      },
      // 获取客户列表
      getUserDetail() {
        var data = {
          current: 1,
          size: 1,
          userId: this.userId
        }
        this.$API.user.reqUserList(data).then(res => {
          if (res.data.code == 200) {
            if (res.data.data.length != 0) {
              this.userData = res.data.data[0]
              console.log(this.userData)
              this.getUserLinkman()
              this.getAgreList()
              this.getDepartment()
            } else {
              this.userData = []
            }
          } else {
            this.$message.error("查询失败！");
          }
        })
      },
      // 获取合同列表
      getAgreList() {
        var data = {
          current: 1,
          size: 100,
          customId: this.userData.userId
        }
        this.$API.agreement.reqContractList(data).then(res => {
          if (res.data.code == 200) {
            if (res.data.data.length != 0) {
              this.agreList = res.data.data[0]
              console.log(this.agreList)
            } else {
              this.agreList = []
            }
          } else {
            this.$message.error("查询失败！");
          }
        })
      },
      // 获取客户类型列表
      async getDictList1() {
        // 解构出参数    
        const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: 'CustomType'
        }
        let result = await this.$API.dict.reqDictList(data)
        // this.total = result.data.total;
        this.dictList1 = result.data.data
      },
      // 获取省列表
      async getDictList() {
        // 解构出参数

        const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: 'province'
        }
        let result = await this.$API.dict.reqDictList(data)
        // this.total = result.data.total;
        this.dictList = result.data.data

      },
      // 获取市列表
      async getCityList() {
        // 解构出参数
        this.userData.city = ''
        const { current, size, dictVar } = this;
        var data = {
          current: 1,
          size: 100,
          dictVar: this.userData.province
        }
        let result = await this.$API.dict.reqDictList(data)
        // this.total = result.data.total;
        this.cityList = result.data.data
      },
      //  添加省
      addDict() {
        // 解构出参数        
        var data = this.dictData;
        this.dictData.dictValue = this.dictData.dictKey
        this.$API.dict.reqAddDict(data).then(res => {
          if (res.data.code == 200) {
            this.$message.success("添加成功！");
            this.dialogFormVisible = false;
            this.dictData = ''
            this.getDictList();
            // this.reload();
          } else {
            this.$message.error("添加失败！");
          }
        })
      },
      // 添加市
      addCity() {
        // 解构出参数        
        var data = this.cityData;
        this.cityData.dictVar = this.dictData.dictKey
        this.cityData.dictKey = this.cityData.dictValue
        this.$API.dict.reqAddDict(data).then(res => {
          if (res.data.code == 200) {
            this.$message.success("添加成功！");
            this.dialogFormVisible1 = false;
            this.cityData = ''
            this.getCityList();
            // this.reload();
          } else {
            this.$message.error("添加失败！");
          }
        })
      },
      Detail(vl) {

        const tolink = this.$router.push({
          path: '/agreementDetails',
          query: { contractId: vl.contractId, customId: vl.customId, secondRepresentative: vl.secondRepresentative, goBackCustomFlag: 1 }
        });
        window.open(tolink.href, '_self')
      }
    },
  }

</script>
<style scoped>
  @import "../../../style/style.css";

  .bx>>>.el-form-item__content {
    width: 300px !important;
    /* border: 1px solid #000; */
  }

  .bx>>>.el-form-item__label {
    font-size: 16px;
  }

  .bx>>>.el-textarea__inner {
    height: 200px !important;
  }

  .bx>>>.el-input__suffix {
    left: 150px;

  }

  .bx>>>.el-form-item {
    margin-bottom: 10px;
  }

  .bx ul li p .title {
    color: #888;
    margin-right: 20px;

  }

  .bx ul li p .blue {
    color: #fe0100;
    /* margin-right: 20px; */
  }

  .el-input,
  .el-select,
  .el-date-picker {
    border: 1px solid #b6b6b6;
    border-radius: 50px;
    overflow: hidden;
    width: 300px;
    position: relative;
    top: 0;
  }

  .add>>>.el-dialog {
    position: relative;
    margin: 0 auto 50px;
    border-radius: 15px;
    box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
    box-sizing: border-box;
    width: 500px;
    overflow: hidden;
  }

  .add>>>.el-input__suffix {
    text-align: right;
  }

  .add>>>.el-select .el-input {
    width: 100%;
  }

  .add>>>.el-form-item__content {
    text-align: right;
    padding-right: 50px;
  }

  .add>>>.el-radio-group {
    margin-right: 100px;
    /* margin-top: 30px; */
  }
</style>